﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SchoolAreaList.aspx.cs" Inherits="Education_SchoolAreaList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>学区列表</title>
    
    <link href="../Common/css/main.css" rel="stylesheet" type="text/css" />    
    <script type="text/javascript" src="../Common/Js/jquery.js"></script>
    <script type="text/javascript" src="../Common/Js/common.js"></script>
    <script type="text/javascript" src="../Common/Js/msg.js"></script>
    <script type="text/javascript" src="../Common/Js/xTree/dhtmlxcommon.js"></script>
    <script type="text/javascript" src="../Common/Js/xTree/dhtmlxtree.js"></script>
    <link href="../Common/css/dhtmlxtree.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
window.onload = InitSchoolAreaList;
var activate = 1;
var tree;

function InitSchoolAreaList()
{
    tree=new dhtmlXTreeObject('treeBox',"100%","100%",0);
    tree.setImagePath("../Common/images/xTreeImgs/");
    
    var title = tree.insertNewChild(0, -2, '教育局', 0, "orgClose.png", "organization.png", "orgClose.png", ""); 
    
    var id = -1;
    var FirstID = 0;
    
     PageMethods.GetSchoolArea(function(succ)
     {
        if(succ.length > 0)
        {
            for(var i = 0; i<succ.length; i++)
            {
                if (FirstID == 0)
                    FirstID = succ[i].RID;

                tree.insertNewChild(-2,succ[i].RID,succ[i].SchoolAreaName,0,"group.gif","group.gif","group.gif","");
            }
        }
        else
            //showMassgeBox("提示","不存在任何学区，请先添加学区",1,null);  
            self.parent.showMassgeBox('提示','不存在任何学区，请先添加学区'); 
            
        //默认的焦点在树上的教育局结点
        FirstID = 0;
        
//        if (FirstID != 0)
//        {
            self.parent.currCauseID = FirstID;
            //tree.selectItem(self.parent.currCauseID, true);
            tree.selectItem(-2, true);
            self.parent.frames["right"].location  = "EducationUserGrid.aspx?id="+FirstID
//        }
    
        tree.setItemStyle(id,"../Common/css/");
        tree.setOnClickHandler(treeOnClick);
     },function(err)
     {
        self.parent.showMassgeBox("提示",CAUSE_FAIL,1,null);   
     })    
	
}

//过滤用户信息，根据学区分类
function treeOnClick(id)
{
    if(activate == 0)
    {
        tree.selectItem(self.parent.currCauseID, false);
        self.parent.frames["right"].showMassgeBox('提示','您还有未保存的项,请保存后再切换');
        return;
    }

    if(id > 0)
    {
        self.parent.currCauseID = id;
        self.parent.frames["right"].location  = "EducationUserGrid.aspx?id="+id;
    }
    else
    {
        if(id == -2)
        {
            self.parent.currCauseID = 0;
            self.parent.frames["right"].location  = "EducationUserGrid.aspx?id=0";
        }
            
        //if(self.parent.currCauseID != null && self.parent.currCauseID > 0)
        //   tree.selectItem(self.parent.currCauseID, false);
    }
}




</script>
</head>

<body>
<form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
         <ContentTemplate>
	        <div class="oneTreeBody">
                    <div class="treeMain">
                         <div style="height:95%; width:170px; overflow:auto;" id="treeBox"></div>
      		        </div>
            </div>  
         </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
